<script setup lang="ts">
import { useRouter } from "vue-router";
import { ref } from "@vue/reactivity";
import headers from "@/components/common/headers.vue";
import footers from "@/components/common/footers.vue";
import navs from "@/components/complaint/navs.vue";
import personInfor from "@/components/complaint/personInfor.vue";
import enterprise from "@/components/complaint/enterprise.vue";
import complaintInfor from "@/components/complaint/complaintInfor.vue";
import success from "@/components/complaint/success.vue";
// 路由管理
const router = useRouter();
// 打开页面
let open = (path: string): void => {
  if (!path) return;
  router.push({ path });
};
// 投诉类型:个人投诉/企业投诉
let types = ref(0);
let step = ref(0);
</script>

<template>
  <div class="complaint">
    <!-- 头部信息 -->
    <headers nexts="个人中心" />

    <!-- 中间内容区域 -->
    <div class="main">
      <!-- 个人投诉/企业投诉 -->
      <div class="personEnterprise" v-if="step == 0">
        <button @click.stop="types = 0" :class="types == 0 ? 'btn' : ''">
          个人投诉
        </button>
        <button @click.stop="types = 1" :class="types == 1 ? 'btn' : ''">
          企业投诉
        </button>
      </div>
      <h1 v-else>{{ types ? "企业投诉" : "个人投诉" }}</h1>
      <!-- 进度条 -->
      <navs
        :step="step"
        :list="
          types
            ? ['企业投诉', '投诉信息', '完成投诉']
            : ['个人投诉', '投诉信息', '完成投诉']
        "
      />
      <!-- 填写个人信息表单内容 -->
      <template v-if="step == 0">
        <personInfor v-if="types == 0" :types="types" v-model:step="step" />
        <enterprise v-else v-model:step="step" />
      </template>
      <!-- 填写企业信息表单内容 -->
      <!-- 投诉信息 -->
      <complaintInfor v-model:step="step" v-else-if="step == 1" />
      <!-- 完成投诉 -->
      <success v-else @open="open" />
    </div>

    <!-- 底部单位信息 -->
    <footers />
  </div>
</template>

<style scoped lang="scss">
.complaint {
  width: 100%;
  padding-top: 45px;
  // 背景图片
  background: #f1f2f3 url("@/assets/my/bg.webp") no-repeat fixed center top;
  background-size: 100% 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px 0px;
}
.main {
  width: 1000px;
  height: 768px;
  // 竖直居中
  @include flexColumnCenter;
  gap: 0px 16px;
  background-color: #fff;
  box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  margin-bottom: 64px;
  padding-top: 48px;
}
// 标题头
h1 {
  font-size: 32px;
  font-weight: 600;
  color: #333333;
}
.personEnterprise {
  @include flexCenter;
  gap: 0px 32px;
  > button {
    width: 260px;
    height: 48px;
    background-color: #e5e5e5;
    border-radius: 8px;
    font-size: 20px;
    font-weight: 600;
    color: #909399;
    cursor: pointer;
    transition: all 0.1s;
  }
  .btn {
    color: #fff;
    background: linear-gradient(90deg, #3dc1ff 0%, #2163e0 100%) !important;
  }
}
</style>
